if( SERVER ) then
	AddCSLuaFile( "shared.lua" )
	SWEP.Weight	= 5
	SWEP.AutoSwitchTo = false
	SWEP.AutoSwitchFrom = false
end

if( CLIENT ) then
	SWEP.PrintName	= "Pickpocket"
	SWEP.Slot	= 4
	SWEP.SlotPos	= 1
	SWEP.DrawAmmo	= false
	SWEP.DrawCrosshair = false
end

SWEP.Base		= "weapon_base"

SWEP.Author		= "Enrico"
SWEP.Instructions	= "Voler une arme. Tu doit viser ta cible."
SWEP.Contact		= ""
SWEP.Purpose		= ""

SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none" 
  
SWEP.ViewModel      = ""
SWEP.WorldModel   = ""

util.PrecacheSound("weapons/iceaxe/iceaxe_swing1.wav")

function SWEP:Initialize()
	if( SERVER ) then
		self:SetWeaponHoldType( "normal" )
	end
end

function SWEP:PrimaryAttack()
	self.Weapon:SetNextPrimaryFire(CurTime()+5)
	self.Owner:SetAnimation( PLAYER_ATTACK1 )
	self.Weapon:EmitSound("weapons/iceaxe/iceaxe_swing1.wav", 50)
	if CLIENT then return end
 	local trace = self.Owner:GetEyeTrace()
	if trace.HitPos:Distance(self.Owner:GetShootPos()) <= 60 then
		if trace.Entity:IsValid() and trace.Entity:IsPlayer() and trace.Entity:Team() ~= self.Owner:Team() then
			if trace.Entity:GetAimVector():DotProduct( self.Owner:GetAimVector() ) > 0 then
				local tab = {}
				for _,v in pairs(gmod.GetGamemode().PickableSweps) do
					if trace.Entity:HasWeapon(v) and trace.Entity:GetActiveWeapon() ~= v then
						table.insert(tab, v)
					end
				end
				if #tab > 0 then
					local Rand = math.random(1, #tab)
					local Weap = tab[Rand]
					self.Owner:Give(Weap)
					trace.Entity:StripWeapon(Weap)
					self.Owner:StripWeapon("weapon_pickpocket")
				end
			end
		end
	end
end

function SWEP:SecondaryAttack()
end

function SWEP:DrawWeaponSelection( x, y, wide, tall, alpha )  
	draw.SimpleText( "g", "CSSelectIcons", x + wide/2, y + tall*0.2, Color( 255, 210, 0, 255 ), TEXT_ALIGN_CENTER )
end